<template>
    <div>
        <headerSearch title="新闻详情"></headerSearch>
        <div class="pagecontent main_news_detail" style="background-color: #fff; margin-bottom: 0; overflow-x:hidden;">
            <!-- 标题 -->
            <h2>{{newsInfo.Title}}</h2>
            <div class="business_lists" style="border-bottom: none;">
                <div class="business_left" @click="jumpCompany()">
                    <img class="auth_img" :src="newsInfo.compnay_img" v-if="newsInfo.compnay_img" alt="">
                    <img class="auth_img" src="../common/images/youquan.png" alt="" v-else>
                </div>
                <div class="business_desc" @click="jumpCompany()">
                    <h5>{{newsInfo.compnay}}</h5>
                    <p>{{newsInfo.summary}}</p>
                </div>
                <div class="btn_small_red">
                    <button @click="jumpCompany()">查看</button>
                </div>
            </div>
            <!-- 内容 -->
           
            <div class="main_news_detail_content" v-html="newsInfo.detail">
               <!-- {{newsInfo.detail}} -->
            </div>
        </div>
    </div>
</template>

<script>
import headerSearch from '../public/header-search.vue';
    export default {
        data() {
            return {
                newsInfo:[],
                id: ''
            }
        },
        mounted() {
            this.id = this.$route.query.id;
            //获取活动信息
            this.getnewsInfo();
        },
        methods:{
            getnewsInfo(){
                console.log(this.id);
                this.$fetch(this.$path + '/index.php/api/NewDetail/'+this.id).then((response) => {
                    console.log('新闻详情', response); 
                    if(response.code == 200) {
                        this.newsInfo = response.data;
                        // this.newsInfo.detail = this.newsInfo.detail.replace(new RegExp('/userimg','g'),"http://s143.nicebox.cn/userimg");
                        if(this.newsInfo.detail.indexOf("http://s143js.nicebox.cn") == -1 ){
                            this.newsInfo.detail = this.newsInfo.detail.replace(new RegExp('/userimg','g'),"http://s143.nicebox.cn/userimg");
                        }else{
                            this.newsInfo.detail = this.newsInfo.detail;
                        }
                    }
                })
            },
            //跳转到企业主页
            jumpCompany(){
                if(this.$system != 'ios'){
                    this.$router.push({path: 'userCenter/companyIndex', query: {cp_id: this.newsInfo.c_id}}); 
                }else{
                    window.location.href = '/userCenter/companyIndex?cp_id=' + this.newsInfo.c_id;
                }  
                
            },
            //沟通跳转到聊天页面
            jumpinformation() {
                this.$router.push({path: '/information', query: {id: this.id}}); 
            }
        },
        components: {
            headerSearch,
        },
    }
</script>

<style>
/* 标题 */
.main_news_detail h2 {
    font-size: 0.36rem;
    color: #333;
    text-align: left;
    padding: 0.2rem;
}
/* 内容 */
.main_news_detail_content {
    font-size: 0.3rem;
    color: #333;
    padding: 0 .2rem;
    text-align: left;
    line-height: .46rem;
    font-family: Source, "微软雅黑";
    max-width: 100%;
    overflow-x: hidden;
}

.main_news_detail_content img {
    height: auto !important;
    /* width: 100% !important; */
    max-width: 100%;
    max-height: 100%;
}
/* .main_news_detail_content p img {
    height: auto !important;
    width: 100% !important;
    max-width: 100%;
    max-height: 100%;
} */

/* .main_news_detail_content .news_detail_img {
    padding: 0.4rem 0;
    box-sizing: border-box;
    text-align: center;
}
.main_news_detail_content .news_detail_img img {
    width: 7.1rem;
    height: 3rem;;
} */
.main_news_detail_content .main_left_nomove_menu0 {
    min-width: 100% !important;
    max-width: 100%;
    max-height: 100%;
    overflow-x: hidden !important;
}

</style>